package Utils;

import java.util.Arrays;
import java.util.Random;

public class ArraysDemo {
    public static void main(String[] args) {
        int[] arr = new int[6];
        Arrays.fill(arr, 6);
        System.out.println("fill: " + Arrays.toString(arr));
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            arr[i] = random.nextInt(101);
        }
        System.out.println("reassign: " + Arrays.toString(arr));
        int head = arr[0];
        Arrays.sort(arr);
        System.out.println("sort: " + Arrays.toString(arr));
        int p = Arrays.binarySearch(arr, head);
        System.out.println("search the first element of arr before sort: " + p);
        int[] newArr = Arrays.copyOf(arr, arr.length);
        System.out.println("newArr from copy equals to arr: " + Arrays.equals(arr, newArr));
    }
}
